Skip to contentSkip to conversation

Hoping someone can help me (Assertion `frames <= snd_pcm_mmap_avail(pcm)' failed.)

DISCUSSION Niels Christian Ørgaard 3 participants 5 messages Mar 10, 2004 – Mar 11, 2004

lore
Share & tools
lore
#0 lore raw

Hey ....

This is the nth day I'm stuck reading the ALSA-documentation over and over again, and I'm at a loss figuring out whats wrong.

Basically, I have a running thread capturing data from an ALSA-device, and within useconds I get: "samptest: pcm.c:5889: snd_pcm_mmap_commit:
Assertion `frames <= snd_pcm_mmap_avail(pcm)' failed." (samptest is the name of my executable)

The reason for me being so confused is that this occures at the call "snd_pcm_readi(snd_pcm_t *, void *, snd_pcm_uframes_t )", which for starters ain't mmap :) I use "snd_pcm_delay(snd_pcm_t *, snd_pcm_sframes_t *)" to verify that there is sufficient data in the queue, before calling readi(), since I halfway expected that the above error in some obscure way was from me trying to read too much from the queue, but this one just informs me that there are the 385 samples (24ms), which happens to be the buffer-size (periods set to 4, buffersize_near set to 48). I have tried to pass "385","48" and the result of delay() as the amount, just to make sure.
I have found that if I increase my buffer-size to 3 times its current level, I can avoid the above error (at least for the some seconds I leave it running), but this incurs an unacceptably high latency. I currently require that latency be kept quite low, and with OSS I have no problem having a buffer-size ~= 6 usec. Unfortunately, I tend to get overruns when I increase my buffer-size to a level where I do not get the above error.

I hope someone can help me, or point me in the direction of a documentation I can understand and use (honestly, too often I've found that the documentation is "insufficient" - at least for me)

Cheers,
/Niels Chr.

Signature · 1 line
My sense of self is fragile as it is without someone stealing me from me.
#1 lore raw

ons, 10.03.2004 kl. 18.32 skrev Niels Christian Ørgaard:

Quoted 10 lines

Hey ....

This is the nth day I'm stuck reading the ALSA-documentation over and over again, and I'm at a loss figuring out whats wrong.

Basically, I have a running thread capturing data from an ALSA-device, and within useconds I get: "samptest: pcm.c:5889: snd_pcm_mmap_commit:
Assertion `frames <= snd_pcm_mmap_avail(pcm)' failed." (samptest is the name of my executable)

Quoted 5 lines

The reason for me being so confused is that this occures at the call "snd_pcm_readi(snd_pcm_t *, void *, snd_pcm_uframes_t )", which for starters ain't mmap :) I use "snd_pcm_delay(snd_pcm_t *, snd_pcm_sframes_t *)" to verify that there is sufficient data in the queue, before calling readi(),

Did you remember to call snd_pcm_avail_update() right before calling readi()? The docs imply that snd_pcm_delay does not update the value returned by the "snd_pcm_mmap_avail" in the assertion, but snd_pcm_avail_update() does (by using the latest value from stuff like snd_pcm_delay or IRQ handlers, so call it after snd_pcm_delay).

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

#2 lore raw
Quoted 17 lines · Ove Kaaven

ons, 10.03.2004 kl. 18.32 skrev Niels Christian ?rgaard:

Quoted 10 lines

Hey ....

This is the nth day I'm stuck reading the ALSA-documentation over and over again, and I'm at a loss figuring out whats wrong.

Basically, I have a running thread capturing data from an ALSA-device, and within useconds I get: "samptest: pcm.c:5889: snd_pcm_mmap_commit:
Assertion `frames <= snd_pcm_mmap_avail(pcm)' failed." (samptest is the name of my executable)

Quoted 5 lines

The reason for me being so confused is that this occures at the call "snd_pcm_readi(snd_pcm_t *, void *, snd_pcm_uframes_t )", which for starters ain't mmap :) I use "snd_pcm_delay(snd_pcm_t *, snd_pcm_sframes_t *)" to verify that there is sufficient data in the queue, before calling readi(),

Quoted 5 lines

Did you remember to call snd_pcm_avail_update() right before calling readi()? The docs imply that snd_pcm_delay does not update the value returned by the "snd_pcm_mmap_avail" in the assertion, but snd_pcm_avail_update() does (by using the latest value from stuff like snd_pcm_delay or IRQ handlers, so call it after snd_pcm_delay).

This call is required only for mmap access not for r/w access.

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

#3 lore raw
Quoted 10 lines · Jaroslav Kysela
Quoted 8 lines · Ove Kaaven

ons, 10.03.2004 kl. 18.32 skrev Niels Christian ?rgaard:

Quoted 6 lines

The reason for me being so confused is that this occures at the call "snd_pcm_readi(snd_pcm_t *, void *, snd_pcm_uframes_t )", which for starters ain't mmap :) I use "snd_pcm_delay(snd_pcm_t *, snd_pcm_sframes_t *)" to verify that there is sufficient data in the queue, before calling readi(),

Quoted 8 lines
Quoted 5 lines

Did you remember to call snd_pcm_avail_update() right before calling readi()? The docs imply that snd_pcm_delay does not update the value returned by the "snd_pcm_mmap_avail" in the assertion, but snd_pcm_avail_update() does (by using the latest value from stuff like snd_pcm_delay or IRQ handlers, so call it after snd_pcm_delay).

This call is required only for mmap access not for r/w access.

I had tried using avail_update(), not finding anything telling me that it was mmap-only. I stopped, as it would always return 0, and subsequent readi()'s produced 0 samples.

/Nc

Signature · 2 lines
"An object is an object, not a pointer. However, objects are accessed
through a reference, which in implementation, is typically a pointer."
#4 lore raw
In reply to Niels Christian Ørgaard
Quoted 9 lines · Niels Christian ?rgaard

Hey ....

This is the nth day I'm stuck reading the ALSA-documentation over and over again, and I'm at a loss figuring out whats wrong.

Basically, I have a running thread capturing data from an ALSA-device, and within useconds I get: "samptest: pcm.c:5889: snd_pcm_mmap_commit:
Assertion `frames <= snd_pcm_mmap_avail(pcm)' failed." (samptest is the name of my executable)

Can you run gdb with your code and send me backtrace?

Quoted 3 lines

The reason for me being so confused is that this occures at the call "snd_pcm_readi(snd_pcm_t *, void *, snd_pcm_uframes_t )", which for starters ain't mmap :) I use "snd_pcm_delay(snd_pcm_t *,

We use almost always mmap even for r/w access (which is emulated in alsa-lib).

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click